import React from 'react';
import classNames from 'classnames';
import {Icon} from 'antd-mobile';

const svgs = ['calendar', 'cart', 'center', 'edit', 'home', 'material',
  'menu', 'password', 'schedule', 'delete', 'round_close',
  'switch'];
const CustomIcon = ({type, className = '', size = 'md', ...restProps}) => {
  if (svgs.indexOf(type) < 0) {
    return <Icon type={type} className={className} size={size} {...restProps} />;
  }
  type = require(`./svg/${type}.svg`);
  let cls = classNames('am-icon', `am-icon-${type.default.id}`, `am-icon-${size}`, className);
  return (
    <svg className={cls} {...restProps}>
      <use xlinkHref={`#${type.default.id}`} />
    </svg>
  );
};
export default CustomIcon;
